package com.gupao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gupao.jwt.JwtTokenUtils;
import com.gupao.jwt.PassToken;
import com.gupao.jwt.UserLoginToken;
import com.gupao.model.User;
import com.gupao.service.UserService;

@Controller
public class UserController extends BaseController {
	@Autowired
	UserService userService;

	@RequestMapping("/login")
	@ResponseBody
//	@UserLoginToken
//	@PassToken
	public String login(@Param("name") String name, @Param("password") String password) {
		User user = userService.login(name, password);
		if (user == null) {
			return "login fail";
		} else {
			return "success:" + JwtTokenUtils.getToken(user);
		}
	}

	@RequestMapping("/getUid")
	@ResponseBody
//	@UserLoginToken
	public String getUid() {
		return super.getUid();
	}
}
